<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      
      <el-form-item label="专项名称" prop="governCheckName">
        <el-input
          v-model="queryParams.governCheckName"
          placeholder="请输入专项名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item label="检查时间" prop="governCheckTime">
        <el-input
          v-model="queryParams.governCheckTime"
          placeholder="请输入检查时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item label="检查人员名称" prop="governCheckUserId">
        <el-input
          v-model="queryParams.governCheckUserId"
          placeholder="请输入检查人员名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['check:governCheckTaskPlanItem:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['check:governCheckTaskPlanItem:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['check:governCheckTaskPlanItem:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['check:governCheckTaskPlanItem:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="governCheckTaskPlanItemList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!--<el-table-column label="${comment}" align="center" prop="id" />
      <el-table-column label="计划ID" align="center" prop="governPlanId" />
      <el-table-column label="下发专项任务ID" align="center" prop="governCheckTaskItemId" />
      <el-table-column label="下发任务ID" align="center" prop="governCheckTaskId" />-->
      <el-table-column label="专项名称" align="center" prop="governCheckName" />
      <el-table-column label="专项检查内容" align="center" prop="governCheckContent" />
      <el-table-column label="专项检查方式" align="center" prop="governCheckWay" />
      <el-table-column label="专项检查依据" align="center" prop="governCheckBasis" />
      <el-table-column label="专项检查适用场合" align="center" prop="governApplicablePlace" />
      <el-table-column label="检查时间" align="center" prop="governCheckTime" />
      <el-table-column label="检查结果" align="center" prop="governCheckSource" />
      <el-table-column label="是否符合" align="center" prop="governCheckConform" />
      <el-table-column label="是否标记" align="center" prop="governCheckSign" />
      <el-table-column label="检查人员ID" align="center" prop="governCheckUserName" />
      <el-table-column label="检查人员名称" align="center" prop="governCheckUserId" />
      <el-table-column label="删除标志" align="center" prop="governDeleted" />
      <el-table-column label="创建人" align="center" prop="governCreateBy" />
      <el-table-column label="创建时间" align="center" prop="governCreateDate" />
      <!--<el-table-column label="修改人" align="center" prop="governUpdateBy" />
      <el-table-column label="修改时间" align="center" prop="governUpdateDate" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['check:governCheckTaskPlanItem:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['check:governCheckTaskPlanItem:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改专项任务计划检查项对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="计划ID" prop="governPlanId">
          <el-input v-model="form.governPlanId" placeholder="请输入计划ID" />
        </el-form-item>
        <el-form-item label="下发专项任务ID" prop="governCheckTaskItemId">
          <el-input v-model="form.governCheckTaskItemId" placeholder="请输入下发专项任务ID" />
        </el-form-item>
        <el-form-item label="下发任务ID" prop="governCheckTaskId">
          <el-input v-model="form.governCheckTaskId" placeholder="请输入下发任务ID" />
        </el-form-item>
        <el-form-item label="专项名称" prop="governCheckName">
          <el-input v-model="form.governCheckName" placeholder="请输入专项名称" />
        </el-form-item>
        <el-form-item label="专项检查内容">
          <editor v-model="form.governCheckContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="专项检查方式" prop="governCheckWay">
          <el-input v-model="form.governCheckWay" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="专项检查依据" prop="governCheckBasis">
          <el-input v-model="form.governCheckBasis" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="专项检查适用场合" prop="governApplicablePlace">
          <el-input v-model="form.governApplicablePlace" placeholder="请输入专项检查适用场合" />
        </el-form-item>
        <el-form-item label="检查时间" prop="governCheckTime">
          <el-input v-model="form.governCheckTime" placeholder="请输入检查时间" />
        </el-form-item>
        <el-form-item label="检查结果" prop="governCheckSource">
          <el-input v-model="form.governCheckSource" placeholder="请输入检查结果" />
        </el-form-item>
        <el-form-item label="是否符合" prop="governCheckConform">
          <el-input v-model="form.governCheckConform" placeholder="请输入是否符合" />
        </el-form-item>
        <el-form-item label="是否标记" prop="governCheckSign">
          <el-input v-model="form.governCheckSign" placeholder="请输入是否标记" />
        </el-form-item>
        <el-form-item label="检查人员ID" prop="governCheckUserName">
          <el-input v-model="form.governCheckUserName" placeholder="请输入检查人员ID" />
        </el-form-item>
        <el-form-item label="检查人员名称" prop="governCheckUserId">
          <el-input v-model="form.governCheckUserId" placeholder="请输入检查人员名称" />
        </el-form-item>
        <el-form-item label="删除标志" prop="governDeleted">
          <el-input v-model="form.governDeleted" placeholder="请输入删除标志" />
        </el-form-item>
        <el-form-item label="创建人" prop="governCreateBy">
          <el-input v-model="form.governCreateBy" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建时间" prop="governCreateDate">
          <el-input v-model="form.governCreateDate" placeholder="请输入创建时间" />
        </el-form-item>
        <el-form-item label="修改人" prop="governUpdateBy">
          <el-input v-model="form.governUpdateBy" placeholder="请输入修改人" />
        </el-form-item>
        <el-form-item label="修改时间" prop="governUpdateDate">
          <el-input v-model="form.governUpdateDate" placeholder="请输入修改时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listGovernCheckTaskPlanItem, getGovernCheckTaskPlanItem, delGovernCheckTaskPlanItem, addGovernCheckTaskPlanItem, updateGovernCheckTaskPlanItem } from "@/api/check/governCheckTaskPlanItem";

export default {
  name: "GovernCheckTaskPlanItem",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 专项任务计划检查项表格数据
      governCheckTaskPlanItemList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        governPlanId: null,
        governCheckTaskItemId: null,
        governCheckTaskId: null,
        governCheckName: null,
        governCheckContent: null,
        governCheckWay: null,
        governCheckBasis: null,
        governApplicablePlace: null,
        governCheckTime: null,
        governCheckSource: null,
        governCheckConform: null,
        governCheckSign: null,
        governCheckUserName: null,
        governCheckUserId: null,
        governDeleted: null,
        governCreateBy: null,
        governCreateDate: null,
        governUpdateBy: null,
        governUpdateDate: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询专项任务计划检查项列表 */
    getList() {
      this.loading = true;
      listGovernCheckTaskPlanItem(this.queryParams).then(response => {
        this.governCheckTaskPlanItemList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        governPlanId: null,
        governCheckTaskItemId: null,
        governCheckTaskId: null,
        governCheckName: null,
        governCheckContent: null,
        governCheckWay: null,
        governCheckBasis: null,
        governApplicablePlace: null,
        governCheckTime: null,
        governCheckSource: null,
        governCheckConform: null,
        governCheckSign: null,
        governCheckUserName: null,
        governCheckUserId: null,
        governDeleted: null,
        governCreateBy: null,
        governCreateDate: null,
        governUpdateBy: null,
        governUpdateDate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加专项任务计划检查项";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getGovernCheckTaskPlanItem(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改专项任务计划检查项";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateGovernCheckTaskPlanItem(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGovernCheckTaskPlanItem(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除专项任务计划检查项编号为"' + ids + '"的数据项？').then(function() {
        return delGovernCheckTaskPlanItem(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('check/governCheckTaskPlanItem/export', {
        ...this.queryParams
      }, `governCheckTaskPlanItem_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
